﻿using ToolKitIESiteList.Library;
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;

namespace ToolKitManagerIESiteList.UserControls
{
    public partial class ImageAndLabel : UserControl
    {
        private Image CurrentImage;
        private bool _FilterOn;

        public FilterType Filter { get; set; }

        public event EventHandler<FilterEventArgs> FilterClick;

        protected virtual void OnFilterClick(FilterEventArgs e)
        {
            FilterClick?.Invoke(this, e);
        }

        public ImageAndLabel()
        {
            InitializeComponent();
            CurrentImage = pctoff.Image;
            _FilterOn = true;
        }
        public bool FilterOn
        {
            get { return _FilterOn; }
            set
            {
                _FilterOn = value;
                if (value)
                {
                    CurrentImage = pcton.Image;
                }
                else
                {
                    CurrentImage = pctoff.Image;
                }
                if (Enabled)
                {
                    PctFiler.Image = CurrentImage;
                }
                else
                {
                    PctFiler.Image = pctDis.Image;
                }
            }
        }

        [BrowsableAttribute(true)]
        public override string Text
        {
            get
            {
                return Label.Text;
            }

            set
            {
                Label.Text = value;
            }
        }
        private void ImageAndLabel_EnabledChanged(object sender, EventArgs e)
        {
            PctFiler.Image = Enabled ? CurrentImage : pctDis.Image;
        }

        private void ImageAndLabel_Load(object sender, EventArgs e)
        {
            if (!Enabled)
            {
                CurrentImage = pctDis.Image;
            }
            PctFiler.Image = CurrentImage;
        }

        private void PctFiler_Click(object sender, EventArgs e)
        {
            OnFilterClick(new FilterEventArgs(FilterOn));
        }
    }


}
